home *** CD-ROM | disk | FTP | other *** search
/ Champak 40 / Vol 40.iso / games / super_su.swf / scripts / DefineSprite_11_bomb_01 / frame_1 / DoAction.as
Encoding:
Text File  |  2007-04-19  |  1.1 KB  |  47 lines

  1. function mKill()
  2. {
  3.    this._parent.mKillObject(this);
  4. }
  5. function mPhysics(interval)
  6. {
  7.    var newPosX = this.intPosX + this.intVelX * interval;
  8.    var newPosY = this.intPosY + this.intVelY * interval;
  9.    this.intPosX = newPosX;
  10.    this.intPosY = newPosY;
  11. }
  12. function mStepFrame(interval)
  13. {
  14.    this.mPhysics(interval);
  15.    var oChar = this._parent.oChar;
  16.    if(this.intRadius < 1)
  17.    {
  18.       this.intRadius = 15;
  19.    }
  20.    var hit = false;
  21.    var dX = Math.abs(oChar.intPosX - this.intPosX);
  22.    if(dX < 200)
  23.    {
  24.       var arrPnts = oChar.mGetPoints();
  25.       var i = 0;
  26.       while(i < arrPnts.length)
  27.       {
  28.          var dX = this.intPosX - arrPnts[i].x;
  29.          var dY = this.intPosY - arrPnts[i].y;
  30.          var dAbs = Math.abs(Math.sqrt(dX * dX + dY * dY));
  31.          if(dAbs < this.intRadius)
  32.          {
  33.             var hit = true;
  34.          }
  35.          i++;
  36.       }
  37.    }
  38.    if(hit)
  39.    {
  40.       oChar.mCollide("bomb");
  41.    }
  42.    if(Math.abs(this.intPosX - oChar.intPosX) > 300 || this.intPosY > 300 || this.intPosY < -300)
  43.    {
  44.       this.mKill();
  45.    }
  46. }
  47.